﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Messaging;

namespace SimpleChat
{
    /// <summary>
    /// Interaction logic for JoinServerWindow.xaml
    /// </summary>
    public partial class JoinServerWindow : Window
    {
        public JoinServerWindow()
        {
            InitializeComponent();

            Messenger.Default.Register<DialogMessage>(this, this.HandleMessageBox);
        }

        public void HandleMessageBox(DialogMessage message)
        {
            message.ProcessCallback(
                MessageBox.Show(
                    message.Content,
                    message.Caption,
                    message.Button,
                    message.Icon,
                    message.DefaultResult,
                    message.Options
                )
            );
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if(String.IsNullOrWhiteSpace(ViewModel.ViewModelLocator.JoinServerStatic.Username))
            {
                MessageBox.Show("Please provide your username");
                return;
            }

            DialogResult = true;
            Close();
        }
    }
}
